package com.coastline.fruit.common.exception;

import java.io.Serializable;

/**
 * @author Coastline
 * @date 2024/12/28 18:09
 */
public class CoastLineFruitException extends Exception{

    private static final long Serializable = 1515615153121356135L;

    private static final String CUT_LINE = "|";

    private String errorCode;

    private String errorMessage;

    public CoastLineFruitException(String errorCode, String errorMessage) {
        super(new StringBuilder().append(errorCode).append(CUT_LINE).append(errorMessage).toString());
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    public CoastLineFruitException(String errorCode, String errorMessage, Throwable throwable) {
        super(new StringBuilder().append(errorCode).append(CUT_LINE).append(errorMessage).toString(), throwable);
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    public CoastLineFruitException(CoastlineFruitErrorInfo coastlineFruitErrorInfo) {
        this(coastlineFruitErrorInfo.getErrorCode(), coastlineFruitErrorInfo.getErrorMessage());
    }

    @Override
    public String toString() {
        return new StringBuilder().append("{ CoastlineFruitException:")
                .append(errorCode).append(CUT_LINE).append(errorMessage).append(" }").toString();
    }
}
